load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@crates//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")

package(default_visibility = ["//visibility:public"])

config_setting(
    name = "release",
    values = {
        "compilation_mode": "opt",
    },
)

rust_binary(
    name = "bin",
    srcs = ["src/main.rs"],
    rustc_flags = select({
        "//:release": [
            "-Clto=true",
            "-Ccodegen-units=1",
            "-Cpanic=abort",
            "-Copt-level=3",
            "-Cstrip=symbols",
        ],
        "//conditions:default": [
            "-Copt-level=0",
        ],
    }),
    deps = all_crate_deps(normal = True),
)

rust_doc(
    name = "doc",
    crate = ":bin",
)
